package com.gec.system.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gec.system.sevice.SysLoginLogService;
import com.gec.system.system.SysLoginLog;
import com.gec.system.util.Result;
import com.gec.system.vo.SysLoginLogQueryVo;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "日志管理")
@RequestMapping("/admin/system/log")
public class SysLoginLogController {
    @Autowired
    private SysLoginLogService loginLogService;
    @GetMapping("/{page}/{limit}")
    public Result findByPage(@PathVariable("page") Long pageIndex, @PathVariable Long limit, SysLoginLogQueryVo vo){
        Page<SysLoginLog> page = new Page<>(pageIndex, limit);
        IPage<SysLoginLog> sysLoginLogIPage = loginLogService.selectPage(page, vo);
        return Result.ok(sysLoginLogIPage);

    }
    @GetMapping("get/{id}")
    public Result get(@PathVariable Long id) {
        SysLoginLog sysLoginLog = loginLogService.getById(id);
        return Result.ok(sysLoginLog);
    }
    @DeleteMapping("delete/{id}")
    public Result removeById(@PathVariable Long id) {
        boolean removeById = loginLogService.removeById(id);
        return removeById?Result.ok():Result.fail();
    }



    }
